import picamera
import time
import os


# 录制视频
# t 录制时长
def getVideo(fileName,t):
    camera = picamera.PiCamera()
    createPath()
    date = time.strftime("%Y%m%d_%H%M%S", time.localtime())
    filePath = './video/' + fileName + date  + '.h264'
    try:
        camera.resolution = (1080, 720)
        camera.start_recording(filePath)
        camera.wait_recording(t)
        camera.stop_recording()
    finally:
        pass

def createPath():
    path = './video/'
    if os.path.exists(path) == False:
        os.makedirs('./video/')

